//
//  InputManager.cpp
//  GSEngine
//
//  Created by Гукун Александр on 2/5/14.
//  Copyright (c) 2014 SNK. All rights reserved.
//

#include "InputManager.h"
#include <GSEngine/Objects/EntityManager.h>

namespace GSEngine
{
    InputManager* InputManager::m_instance = NULL;

    InputManager::InputManager():m_lastPosition(0)
    {
        m_instance = this;
    }
    InputManager::~InputManager()
    {
        
    }

    // input methods
    void InputManager::beginTouch(const vec2f scrPos, int tapCount, int touchID)
    {
        m_lastPosition = scrPos;
    }
    void InputManager::moveTouch(const vec2f scrPos, int tapCount, int touchID)
    {
        Camera* cam = EntityManager::getInstance()->getCamera();
        vec2f currentPos = scrPos;
        vec2f touchDiffs = (currentPos - m_lastPosition);
//        vec3f camRot = cam->getRotation();
//        cam->setRotation(vec3f(camRot.x + touchDiffs.y/ 1000.0f, camRot.y - touchDiffs.x/ 1000.0f, camRot.z));
        
        vec3f camPos = cam->getPosition();
        //m_lastPosition
        cam->setPosition(vec3f(camPos.x + touchDiffs.x/ 1000.0f, camPos.y - touchDiffs.y/ 1000.0f, camPos.z - 0.1));
        cam->updateWorldMatrix();
        cam->updateViewMatrix();
    }
    void InputManager::endTouch(const vec2f scrPos, int tapCount, int touchID)
    {
        
    }
    void InputManager::cancelTouch(const vec2f scrPos, int tapCount, int touchID)
    {
        
    }
}